<template>
	<view class="p_container">
		<view class="p_top">
		</view>
		<view class="points_card">
			<view class="p_hint">
				<text class="">
					我的积分
				</text>
				<view style="font-size: 28rpx;" @click="jumpRule">
					积分规则说明 〉
				</view>
			</view>
			<view class="p_acount">
				<text>{{pointAcount==null?'暂无积分':pointAcount}}</text>
			</view>
			<view v-if="pointAcount!=null" class="p_msg">
				<text>已兑积分：{{exchangedIntegral}}</text>
				<text>累计总积分：{{historyTotalIntegral}}</text>
			</view>
		</view>
		<view class="points_detail_title">
			<text>积分明细</text>
		</view>
		<view class="p_list">
			<scroll-view :scroll-top="scrollTop" scroll-y="true" class="scroll-Y" @scrolltoupper="upper" @scrolltolower="lower"
			@scroll="scroll">
			<view v-if="pointList.length > 0">
				<view class="item" v-for="(item, index) in pointList" :key="index">
					<view class="item_msg">
						<text class="p_title">{{item.integralDesp}}</text>
						<text class="p_time">{{item.gmtCreate}}</text>
					</view>
					<text class="p_point">+{{item.integralAmount}}</text>
				</view>
			</view>
			<view v-if="pointList.length == 0">
				<noContent></noContent>
			</view>
			</scroll-view>
		</view>
	</view>
</template>

<script>
	import {selectIntegralUser, selectIntegralDetailPage} from '../../common/api/index.js';
	import {_showLoading, _showToast} from '../../common/js/util.js'
	import noContent from '../../components/no-content.vue'
	export default {
		data() {
			return {
				pointList: [],
				scrollTop: 0,
				pointAcount: 0,
				historyTotalIntegral: 0,
				exchangedIntegral: 0
			}
		},
		onShow:function(){
			this._getSelectIntegralUser()
			this._selectIntegralDetailPage()
		},
		components: {
			noContent
		},
		methods: {
			upper() {},
			scroll() {
				this.old.scrollTop = e.detail.scrollTop
			},
			lower() {},
			_selectIntegralDetailPage(){
				_showLoading('加载中,请稍后…')
				let s_userId = uni.getStorageSync('s_userId')
				selectIntegralDetailPage({
					userId: s_userId
				}).then(res => {
					if(res.code == 0) {
						this.pointList = res.data.integralDetailList
						uni.hideLoading()
					} else {
						uni.hideLoading()
					}
				}).catch(err => {
					console.log(err)
				})
			},
			_getSelectIntegralUser() {
				let s_userId = uni.getStorageSync('s_userId')
				selectIntegralUser({
					userId: s_userId
				}).then(res => {
					if(res.code == 0) {
						this.pointAcount = res.data.userIntegralAmount
						this.exchangedIntegral = res.data.exchangedIntegral
						this.historyTotalIntegral = res.data.historyTotalIntegral
					}
				}).catch(err => {
					console.log(err)
				})
			},
			jumpRule() {
				uni.navigateTo({
					url: './rules'
				})
			}
		}
	}
</script>

<style lang="scss">
	page{
		height: 100vh;
		background-color: #FFF;
	}
	.p_container {
		display: flex;
		flex-direction: column;
	}
	.p_top {
		background-color: #3C424F;
		width: 100%;
		height: 200rpx;
		display: flex;
		flex-direction: column;
		justify-content: center;
		align-items: center;
		transform: scaleX(1.3);
		border-bottom-right-radius: 50%;
		border-bottom-left-radius: 50%;
		margin-bottom: 164rpx;
	}
	.p_hint,.p_msg{
		font-size: $font-size-lg;
		font-family: PingFang-SC-Medium, PingFang-SC;
		font-weight: 500;
		color: #FFFFFF;
		line-height: 40rpx;
		display: flex;
		flex-direction: row;
		justify-content: space-between;
		align-items: flex-start;
	}
	.p_hint{
		color: #D6DDFF;
	}
	/* .p_msg{
		justify-content: flex-start;
	} */
	/* .p_msg text{
		margin-right: 40rpx;
	} */
	.points_card{
		position: absolute;
		top: 34rpx;
		left: 50%;
		width: 686rpx;
		height: 320rpx;
		transform: translateX(-50%);
		background: linear-gradient(134deg, #62A7FF 0%, #5C6EFF 100%);
		box-shadow: 0 16rpx 32rpx 0 rgba(100, 122, 252, 0.2);
		border-radius: 16rpx;
		padding: 44rpx 52rpx;
		box-sizing: border-box;
	}
	.p_acount {
		font-size: 72rpx;
		font-family: PingFangSC-Heavy, PingFang SC;
		font-weight: 800;
		color: #FFFFFF;
		line-height: 100rpx;
		padding: 14rpx 0 32rpx 0;
	}
	.p_desc {
		margin-top: 20rpx;
		color: #fff;
		font-size: 26rpx;
	}
	.points_detail_title{
		padding: 32rpx;
		font-size: 36rpx;
		height: 50rpx;
		font-family: PingFangSC-Semibold, PingFang SC;
		font-weight: 600;
		color: #3C424F;
		display: flex;
		flex-direction: row;
		align-items: center;
	}
	.p_list {
		display: flex;
		flex-direction: column;
		height: calc(100vh - 478rpx);
		overflow: scroll;
	}
	.points_detail_title::before{
		content: "";
		display: inline-block;
		height: 80%;
		width: 8rpx;
		height: 32rpx;
		border-radius: 4rpx;
		margin-right: 10rpx;
		background-color: #185AFF;
		margin-top: 6rpx;
	}
	.item{
		padding: 32rpx;
		display: flex;
		flex-direction: row;
		align-items: center;
		justify-content: space-between;
		position: relative;
	}
	.item::after{
		content: "";
		height: 1px;
		transform: scaleY(.5);
		background: #E6E6E6;
		position: absolute;
		right: 0;
		bottom: 0;
		left: 32rpx;
	}
	.item_msg,.p_point{
		font-family: PingFang-SC-Heavy, PingFang-SC;
		display: flex;
		flex-direction: column;
		align-items: flex-start;
		justify-content: center;
	}
	.p_title{
		font-size: $font-size-lg;
		color: #666666;
		line-height: 40rpx;
	}
	.p_time{
		font-size: $font-size-base;
		color: #999999;
		line-height: 34rpx;
	}
	.p_point{
		font-size: 40rpx;
		font-weight: 800;
		color: #333333;
		line-height: 56rpx;
	}
</style>
